home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ov143b.zip / DIALOG.C < prev    next >
C/C++ Source or Header  |  1993-01-04  |  3KB  |  114 lines

  1. /*  004  28-May-87  dialog.c
  2.  
  3.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  4. */
  5.  
  6. #include <stdio.h>
  7. #include "dialog.h"
  8. #include "direct.h"
  9. #include "strmem.h"
  10.  
  11. #ifdef LINT_ARGS                               /* this belongs somewhere else */
  12. char * ALTCALL read_str(int, char *, int);
  13. #else
  14. char * ALTCALL read_str();
  15. #endif
  16.  
  17. /***************************************************************************
  18.                                D B X _ O P E N
  19.  **************************************************************************/
  20.  
  21. void ALTCALL
  22. dbx_open(dbp,options)  /* open a dialog box */
  23. register D_BOX *dbp;
  24. unsigned int options;
  25. {
  26.  
  27.    /* allocate a save area for the text under the box if the caller
  28.       wants the current video image saved */
  29.  
  30.    if (options & DBX_SAVE)
  31.       dbp->save = (char *) Malloc((dbp->nrows+2) * (dbp->ncols+2) * 2);
  32.    else
  33.       dbp->save = NULL;
  34.  
  35.    /* popup a window that is 2 rows and 2 columns larger than the one
  36.       the user wants.  The extra space is for the border around the box. */
  37.  
  38.    popup(dbp->row-1,dbp->col-1,dbp->nrows+2,dbp->ncols+2,dbp->save);
  39.  
  40.    /* display a title if there is one */
  41.  
  42.    if (dbp->title) {
  43.       disp_char_at(' ',dbp->row-1,dbp->col+1);
  44.       disp_str(dbp->title);
  45.       disp_char(' ');
  46.    }
  47. }
  48.  
  49.  
  50. /****************************************************************************
  51.                              D B X _ C L O S E
  52.  ***************************************************************************/
  53.  
  54. void ALTCALL
  55. dbx_close(dbp)         /* close a dialog box */
  56. register D_BOX *dbp;
  57. {
  58.    /* not much to it really, most of the work is done by popdwn() */
  59.  
  60.    if (dbp->save) {
  61.       popdwn(dbp->row-1,dbp->col-1,dbp->nrows+2,dbp->ncols+2,dbp->save);
  62.       free(dbp->save);
  63.    }
  64. }
  65.  
  66.  
  67. /***************************************************************************
  68.                               D B X _ R D F L D
  69.  ***************************************************************************/
  70.  
  71. char *ALTCALL
  72. dbx_rdfld(dbp,dfp)     /* read a dialog box field value */
  73. register D_BOX *dbp;
  74. register D_FLD *dfp;
  75. {
  76.    char *fldval;
  77.  
  78.    dbx_goto(dbp,dfp->row,dfp->col);                    /* start of field  */
  79.  
  80.    return(read_str(dfp->len,dfp->value,dfp->pos));     /* read and return */
  81. }
  82.  
  83.  
  84. #ifndef DBX_MACROS     /* only define following rtns if not defined as macros */
  85.  
  86. /***************************************************************************
  87.                               D B X _ D I S P
  88.  **************************************************************************/
  89.  
  90. void ALTCALL
  91. dbx_disp(dbp,s,ro,co)  /* display text in a dialog box */
  92. register D_BOX *dbp;
  93. char *s;
  94. int ro, co;
  95. {
  96.    disp_str_at(s,dbp->row+ro,dbp->col+co);
  97. }
  98.  
  99.  
  100. /***************************************************************************
  101.                              D B X _ G O T O
  102.  ***************************************************************************/
  103.  
  104. void ALTCALL
  105. dbx_goto(dbp,ro,co)    /* goto a position in dialog box */
  106. register D_BOX *dbp;
  107. int ro,co;
  108. {
  109.    gotorc(dbp->row+ro,dbp->col+co);
  110. }
  111.  
  112. #endif   /* ifndef DBX_MACROS */
  113.  
  114.